<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>用AJAX以JSON方式获取数据</title>
    <script type="text/javascript" src="jquery.min.js"></script>
</head>
<body>
<input type="button" value="通过AJAX获取多个Hero对象111" id="sender">

<div id="messageDiv"></div>

<script>
    $('#sender').click(function(){
        var url="getManyCategory";
        $.post(
            url,
            function(data) {
                console.log(data);
                var categorys = $.parseJSON(data);
                console.log(categorys.length);

                for(i in categorys){
                    var old = $("#messageDiv").html();
                    var category = categorys[i];
                    $("#messageDiv").html(old + "<br>"+category.id+"   -----   "+category.name);
                }
            });
    });
</script>
</body>

</body>
</html>